package com.hbnu.utils;

import org.springframework.beans.BeanUtils;

/**
 * @Auther: hjx
 * @Date: 2023/6/14 08:54
 * @Description:
 */
public class CopyUtil {

    /**
     * 单体复制
     */
    public static <T> T copy(Object source, Class<T> clazz) {
        if (source == null) {
            return null;
        }
        T obj = null;
        try {
            obj = clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        BeanUtils.copyProperties(source, obj);
        return obj;
    }
}

